package com.xxgc.demo.job;
/*
 *
 *   @Author:SJY
 *   @Date: 2023/9/27-09-27-16:27
 *  通过接口来运行的任务
 */

import cn.hutool.extra.mail.MailUtil;
import com.xxgc.demo.http.IGetChp;
import com.xxgc.demo.http.po.ChpPO;
import com.xxgc.demo.http.po.ChpPOData;
import com.xxgc.demo.utils.SpeechSynthesisUtil;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class AddTaskByControllerJob implements Job {
    @Autowired
    private IGetChp iGetChp;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        ChpPO chp = iGetChp.getChp();
        ChpPOData data = chp.getData();
        String text = data.getText();
        MailUtil.send("2506048807@qq.com", "给你一封信", text, false);
        log.info("我是接口调用的，我被执行了");

        SpeechSynthesisUtil synthesisUtil = new SpeechSynthesisUtil();
        //String msg = "从成都开往泸州的长途汽车即将发车了，请乘坐成都开往泸州班次的乘客，携带好行李物品，到3站台检票上车。";
        synthesisUtil.speak(text);
    }
}
